package com.lxy.mychat.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxy.mychat.Bean.ChatItem;
import com.lxy.mychat.Bean.PyqItem;
import com.lxy.mychat.R;

import java.text.SimpleDateFormat;
import java.util.List;

public class PyqItemAdapter extends ArrayAdapter<PyqItem> {
    int resourceid;
    public PyqItemAdapter(@NonNull Context context, int resource, @NonNull List<PyqItem> objects) {
        super(context, resource, objects);
        this.resourceid=resource;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        View view=convertView;
        if (view==null){
            view= LayoutInflater.from(getContext()).inflate(resourceid,null);
        }
        ImageView userimg=view.findViewById(R.id.userimg);
        TextView username=view.findViewById(R.id.username);
        TextView usercontent=view.findViewById(R.id.usercontent);
        ImageView contentimg=view.findViewById(R.id.contentimg);

        PyqItem p=getItem(position);
        userimg.setImageResource(p.getUserimg());
        username.setText(p.getUsername());
        usercontent.setText(p.getPyqcontent());
        contentimg.setImageResource(p.getPyqimg());
        return view;
    }
}
